#include <stdio.h>
int ans = 0;
int main(){
	int a,b,c,d;
	for(int i = 1;i<= 2020 ;i++){
		a = i %10;
		b = ((i-a)/10)%10;
		c = (((i-a)/10-b)/10)%10;
		d = ((((i-a)/10-b)/10-c)/10)%10;
		if(a==2)
		  ans++;
		if(b==2)
		  ans++;
		if(c == 2) 
	          ans++;
		if(d==2) 
		  ans++;
	}
	printf("%d",ans);
}
